package com.thysdy.flowable.vo;

import lombok.Data;

/**
 * @author dongqs
 * @description : 表现层公共返回
 */
@Data
public class BaseReturnVo<T> {

    /**
     * 业务编号
     */
    private Integer code;
    /**
     * 异常信息
     */
    private String message;
    /**
     * 业务数据返回
     */
    private T data;

    public BaseReturnVo() {
    }

    public BaseReturnVo(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public BaseReturnVo(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    // 成功但是无参数
    public static <T> BaseReturnVo<T> success() {
        BaseReturnVo<T> response = new BaseReturnVo<>();
        response.setCode(0);
        response.setMessage("success");
        return response;
    }

    // 成功有参数
    public static <T> BaseReturnVo<T> success(T data) {
        BaseReturnVo<T> response = new BaseReturnVo<>();
        response.setCode(0);
        response.setMessage("success");
        response.setData(data);
        return response;
    }

}
